import createPersistedState from 'vuex-persistedstate'
import * as Cookies from 'js-cookie'
// import cookie from 'cookie'
export default ({ store, req }) => {
    createPersistedState({
        storage: sessionStorage,
        // storage: localStorage,
        key: 'store_boycot_blog'
        // paths: ['/theme'],
        // storage: {
        //     getItem: (key) => {
        //         // See https://nuxtjs.org/guide/plugins/#using-process-flags
        //         if (process.server && req.headers.cookie) {
        //             console.log(key, req.headers.cookie, 'key, value')
        //             const parsedCookies = cookie.parse(req.headers.cookie)
        //             return parsedCookies[key]
        //         } else {
        //             return Cookies.get(key)
        //         }
        //     },
        //     // Please see https://github.com/js-cookie/js-cookie#json, on how to handle JSON.
        //     setItem: (key, value) => {
        //         console.log(key, value, 'key, value')
        //         Cookies.set(key, value, { expires: 365, secure: false })
        //     },
        //     removeItem: key => Cookies.remove(key)
        // }
        // storage: {
        //     getItem: key => Cookies.get(key),
        //     setItem: (key, value) => Cookies.set(key, value, { expires: 7 }),
        //     removeItem: key => Cookies.remove(key)
        // }
    })(store)
}
